/**
 * 
 * @param {*} matrix 
 * @description 上下交换 对角线交换
 */
 var rotate = function (matrix) {
    let row = matrix.length
    // 上下交换
    for (let i = 0; i < Math.floor(row / 2); i++) {
        let temp = matrix[i]
        matrix[i] = matrix[row - i - 1]
        matrix[row - i - 1] = temp
    }
    // 对角线交换
    for (let i = 0; i < row - 1; i++) {
        for (let j = i + 1; j < row; j++) {
            let temp = matrix[i][j]
            matrix[i][j] = matrix[j][i]
            matrix[j][i] = temp
        }
    }
    return matrix
};
console.log(rotate([[5, 1, 9, 11], [2, 4, 8, 10], [13, 3, 6, 7], [15, 14, 12, 16]]))
